<template>
    <div class="big-box">
        <div class="nr-center">
            
            <el-table :data="pageData" class="table-data">
                            <el-table-column prop="courseCover" label="头像" width="80" #default="one">
                                <el-image class="FM_img" :src="one.row.profilePic" />
                            </el-table-column>
                            <el-table-column prop="userName" label="账号名" width="150"></el-table-column>
                            <el-table-column prop="nickName" label="用户昵称" width="150"></el-table-column>
                            <el-table-column prop="email" label="邮箱" ></el-table-column>
                            <el-table-column prop="courseIntro" width="120" label="授权" #default="data">
                                <el-tooltip effect="light" content="确认授权？授权后该账号将成为教师账号。" placement="top">
                                    <el-image src="/src/assets/svg/around.svg" class="bj-img" @click="becomeTeacher(data.row.userId)"/>
                                </el-tooltip>
                            </el-table-column>
                            <!-- <el-table-column prop="courseIntro" width="120" label="撤职" #default="data">
                                <el-tooltip effect="light" content="确认撤职？撤职后该账号将成为学生账号。" placement="top">
                                    <el-image src="/src/assets/svg/delete1.svg" class="bj-img" @click="expelTeacher(data.row.userId)"/>
                                </el-tooltip>
                            </el-table-column> -->
                        </el-table>



        </div>
    </div>
</template>

<script setup>
import adminHttp from '@/api/adminHttp';
import { openInfo } from '@/utils/openInfo';
import { onMounted, ref } from 'vue';
const pageData = ref([])


onMounted(()=>{
    getAllStudent()
})

const getAllStudent =()=>{
    adminHttp.getAllStudent().then((res)=>{
        if(res.code==200){
            pageData.value = res.data
            console.log("成功");
            
        }
        console.log("全部学生数据",res);
        
    })
}

//点击授权
const becomeTeacher = (userId)=>{
    adminHttp.becomeTeacher(userId).then((res)=>{
        if (res.code == 200) {
            getAllStudent()
            openInfo("授权成功")
        }
    })
}

</script>

<style scoped>
.big-box {
    display: flex;
    justify-content: center;
}

.nr-center {
    height: 980px;
    border-radius: 10px;
    background-color: rgba(250, 246, 246, 0.504);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25);
    /*阴影 */
    width: 80%;
    margin-top: 15px;
    padding: 20px;
}

.table-data {
    width: 100%;
    border-radius: 10px;
    max-height: 600px;
    margin-top: 10px;
}

.bj-img {
    cursor: pointer;
    transition: transform 0.3s ease-in-out;
}

.bj-img:hover {
    transform: scale(1.1);
}
</style>